using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace BepuUtilities.Collections
{
    /// <summary>
    /// 为引用的类型提供相等比较和哈希。
    /// </summary>
    /// <typeparam name="T">要比较相等和哈希的类型。</typeparam>
    public struct ReferenceComparer<T> : IEqualityComparerRef<T> where T : class
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(ref T a, ref T b)
        {
            return ReferenceEquals(a, b);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public int Hash(ref T item)
        {
            return item.GetHashCode();
        }
    }
}
